/** * Controllers * @module controllers */ define(function (require, exports) { 'use strict'; var $ = require('jquery'); // apptech otp over email var enciphering = require('angular-rsa-encrypt'); var readKey = require('rsaKeySetup'); var rsaJs = require('./../rsa'); require('./../libs/client.min'); function applyScope($scope) { if (!$scope.$$phase) { $scope.$apply(); } } /** * Main controller * @ngInject * @constructor */ function LoginController(lpCoreUtils, lpWidget,$scope, $sce, lpPortal, lpCoreBus, LoginService,rsaDevicePrint,$window, $http, CQService, $interval) { var userId, password; var vc = this, emudraConfigProperty = 'false', customerId = '', userStatus = '', questionActions = ['QUESTION', 'OTPANDQUESTION', 'RSAOTPANDQUESTION'], loginEndpoint, captchaServiceEndPoint, partialsDir = lpCoreUtils.getWidgetBaseUrl(lpWidget) + '/templates/partials/', formPartial = partialsDir + '/form.html', rsaLoginFailNotifyEndpoint, lockSMSEndpoint, emudraEndpoint, checkCustomerExistEndpoint, profileChkEndpoint, rsaAnalyzeEndpoint, generateOTPEndpoint, verifyRsaLoginEndpoint, handleLogin, redirectionUrl, sessInvalidateServiceEndpoint, sessValidateServiceEndpoint; vc.otpFormPartial = partialsDir + '/otpForm.html'; var RIB_BIB_URL = { bibuser:"netbanking/individual", bibaus:"netbanking/OneX", user:"netbanking", bibadmin:"bibadmin/home", merchantpwdreset: "bibadmin/home", 'BBADMIN-CHANGE-PASSWORD': "bibadmin/home", merchant: "bibadmin/home", bibsuperadmin: "bibadmin/home", bocuser: "bibadmin/home", uammaker: "bibadmin/home", uamchecker: "bibadmin/home", pdgmaker: "bibadmin/home", pdgchecker: "bibadmin/home", opsmaker: "bibadmin/home", opschecker: "bibadmin/home", makchkpwdreset:"bibadmin/home", fss_user:"bibadmin/home" } vc.showCaptcha = false; vc.lastCaptchaLogin = false; vc.virtualKeyboard = false; vc.showKeyboard = false; loginEndpoint = lpPortal.root + '/j_spring_security_check'; handleLogin = lpCoreUtils.resolvePortalPlaceholders(lpWidget.getPreference('handleLogin')); rsaLoginFailNotifyEndpoint = lpCoreUtils.resolvePortalPlaceholders(lpWidget.getPreference('rsaLoginFailNotify')); lockSMSEndpoint = lpCoreUtils.resolvePortalPlaceholders(lpWidget.getPreference('lockSMSurl')); emudraEndpoint = lpCoreUtils.resolvePortalPlaceholders(lpWidget.getPreference('emudraUrl')); checkCustomerExistEndpoint = lpCoreUtils.resolvePortalPlaceholders(lpWidget.getPreference('checkCustomerExistUrl')); profileChkEndpoint = lpCoreUtils.resolvePortalPlaceholders(lpWidget.getPreference('profileChkEndpointUrl')); rsaAnalyzeEndpoint = lpCoreUtils.resolvePortalPlaceholders(lpWidget.getPreference('rsaAnalyzeService')); generateOTPEndpoint = lpCoreUtils.resolvePortalPlaceholders(lpWidget.getPreference('generateOTPService')); verifyRsaLoginEndpoint = lpCoreUtils.resolvePortalPlaceholders(lpWidget.getPreference('verifyRSALoginService')); sessInvalidateServiceEndpoint = lpCoreUtils.resolvePortalPlaceholders(lpWidget.getPreference('sessLogoutServiceUrl')); sessValidateServiceEndpoint = lpCoreUtils.resolvePortalPlaceholders(lpWidget.getPreference('sessionValidateService')); captchaServiceEndPoint = lpWidget.getPreference('captchaService'); var getChallengeQuestionUrl = lpCoreUtils.resolvePortalPlaceholders(lpWidget .getPreference('getCQUrl')); var verifyCQAnswerUrl = lpCoreUtils.resolvePortalPlaceholders(lpWidget .getPreference('verifyCQAnswerUrl')); var mailExist = lpCoreUtils.resolvePortalPlaceholders(lpWidget.getPreference('mailExist')); var generateOTPLogin = lpCoreUtils.resolvePortalPlaceholders(lpWidget.getPreference('generateOTPLogin')); var verifyOTPLogin = lpCoreUtils.resolvePortalPlaceholders(lpWidget.getPreference('verifyOTPLogin')); vc.mobileView= false; vc.WebView= false; if(window.screen.width>414){ vc.mobileView= false; }else{ vc.mobileView= true; } var current = new Date(); var blkStart = new Date("Sep 18, 2022 05:00:00"); var blkEnd = new Date("Sep 18, 2022 10:00:00"); if(current.getTime()>blkStart.getTime() && current.getTime() str.length-1) return str; return str.substr(0,index) + chr + str.substr(index+1); } var censorWord = function (str) { var newstr = str; for(var i=1; i<=str.length; i = i+2){ newstr = setCharAt(newstr,i,'*'); } return newstr; } var censorEmail = function (email){ var arr = email.split("@"); return censorWord(arr[0]) + "@" + arr[1]; } // otp over email end function getPostVerifyData(action) { var data = { 'credentialType': action, 'transaction': 'login', 'otpValue': vc.otpValue, 'customerId': customerId, 'userStatus': userStatus, 'devicePrint': rsaDevicePrint.execute(), 'questionID' : vc.challengeQuestionsId, 'question' : vc.challengeQuestions, 'answer' : vc.challengeQuestionAnswer } return data; } lpCoreBus.publish('IDFC-CUSTOMER-FINGERPRINT-FUNCTION') function login(userId, password) { userId = userId; password = password; var falconObj = {}; lpCoreBus.subscribe('IDFC-CUSTOMER-FINGERPRINT', function(data) { falconObj.fingerprint = data.fingerprint, falconObj.cstmFingerprint = data.cstmFingerprint, falconObj.browser = data.browser, falconObj.longitude = data.location ? data.location.longitude : '', falconObj.latitude = data.location ? data.location.latitude : '' }) return LoginService .setup({ loginEndpoint: loginEndpoint }) .login({ j_username: userId, j_password: password, portal_name: lpPortal.name, page_name: lpPortal.page.name, auth_token: 'required', requiredECheck: 'required', captchacode: vc.captcha, userMobNum: vc.mobNo, deviceConfig: JSON.stringify(falconObj) }); } function verifyBeforeLogin(userId) { return LoginService .setup({ profileChkEndpoint: profileChkEndpoint }) .preLoginChk({ logName: userId }); } function getSuccessView(response) { if($window.location.protocol.indexOf('file:') === 0) { response.successView = null; } if ( response.successView ) { $window.location.replace(lpPortal.root + response.successView); } else { var currentLocation; if($window.location.protocol.indexOf('file:') === 0) { currentLocation = $window.location.pathname.split('//')[0] + $window.location.search + $window.location.hash; } else { currentLocation = $window.location.href; } handleLoginRedirection(); } } function checkUserGroupName() { LoginService.getGroup(handleLogin).success(function(data) { /* if (data.userGroupName == 'user' || data.userGroupName == 'bibaus' || data.userGroupName == 'bibuser') { checkMailExistLogin(); } else { redirectionUrl = RIB_BIB_URL[data.userGroupName]; $window.location.href = lpPortal.root + '/' + redirectionUrl; } */ redirectionUrl = RIB_BIB_URL[data.userGroupName]; $window.location.href = lpPortal.root + '/' + redirectionUrl; }) } vc.verifyOTPforLogin = function(isFormValid, otpValue) { vc.errorSpin = true; if(!isFormValid) { return; } var data = { credentialType: 'OTP', otpValue: otpValue } LoginService.setup({ verifyOTPLogin: verifyOTPLogin, data: data }).verifyOTPLoginService().success(function(data) { otherCallsAfterPasswordValid(vc.doCustomLoginResponse); return false; handleLoginRedirection(); }).error(function(error) { vc.errorSpin = false; vc.LoginOtpValue = ''; if(error.cd == '111') { vc.disableOtpSubmitBtn = true; } vc.otperror = { happened: true, msg: error.rsn }; vc.otpsuccess = { happened: false, msg: '' }; }) //handleLoginRedirection(); } function handleLoginRedirection() { var handleLoginNew = lpCoreUtils.resolvePortalPlaceholders(lpWidget.getPreference('handleLoginNew')); LoginService.getGroup(handleLoginNew).success(function(data) { if (data.userGroupName == 'user') { $window.location.href = lpPortal.root + '/' + 'netbanking'; } else if (data.contextUcicRelId != null) { var individual = false; var soleprop = false; var aususer = false; for (var key in data.contextUcicRelId) { if (data.contextUcicRelId[key] === '1111' && data.solepropRel[key] == 'N') { individual = true; }else if(data.contextUcicRelId[key] === '1111' && data.solepropRel[key] == 'Y'){ soleprop = true; }else if(data.contextUcicRelId[key] ==" "){ aususer = true; }else if(data.contextUcicRelId[key]==='6666'){ aususer = true; } } if(individual){ $window.location.replace(lpPortal.root + '/' + 'netbanking'); }else if(soleprop){ redirectionUrl = RIB_BIB_URL[data.userGroupName]; $window.location.replace(lpPortal.root + '/' + redirectionUrl); }else if(aususer){ redirectionUrl = RIB_BIB_URL[data.userGroupName]; $window.location.replace(lpPortal.root + '/' + redirectionUrl); } individual = false; soleprop = false; aususer = false; } else { redirectionUrl = RIB_BIB_URL[data.userGroupName]; $window.location.href = lpPortal.root + '/' + redirectionUrl; } }).error(function(error) { //vc.showOTPtoLogin = true; //vc.LoginOtpValue = ''; /* vc.otperror = { happened: true, msg: error.rsn }; vc.otpsuccess = { happened: false, msg: '' }; */ }); } /** * Handle successful authentication attempt */ function handleSuccessfulLogin(response) { if (emudraConfigProperty === 'true') { LoginService .setup({ emudraEndpoint: emudraEndpoint }) .emudra() .success(function (data, status, headers, config){ setXsrfToken(headers); getSuccessView(response); }) .error(function (error, status, headers, config){ setXsrfToken(headers); vc.user.password = ''; if (error.cd === '501') { vc.loginError = error.rsn; vc.errorSpin = false; } }); } else { getSuccessView(response); } } function attemptCheckLogin(userId) { vc.errorSpin = true; return verifyBeforeLogin(userId).success(function(response, status, headers, config){ setXsrfToken(headers); doCustomLogin(vc.user.id, vc.user.password); }) .error(function (error, status, headers, config){ setXsrfToken(headers); vc.errorSpin = false; }); } function doCustomLogin(userId, password) { // adob routing var urlLength = window.location.href.length; var keyIndex = location.href.search('='); if(keyIndex != -1) { var karmaFlag = location.href.search('karmaFirst'); var mfFlagNFO = location.href.search('mutualFundsNFO'); var mfFlag = location.href.search('mutualFunds'); if(karmaFlag != -1){ var rountingKey = location.href.slice(keyIndex+1, urlLength); var rountingKey = location.href.substring(location.href.indexOf('=')+1); var a = rountingKey.split('&'); var finalArray = []; finalArray.push(a[0],a[1].split('=')[1],a[2].split('=')[1],a[3].split('=')[1]); window.sessionStorage.setItem('page', finalArray[0]); window.sessionStorage.setItem('cause', finalArray[1]); window.sessionStorage.setItem('partner', finalArray[2]); window.sessionStorage.setItem('frequency', finalArray[3]); }else if(mfFlagNFO != -1){ var rountingKey = location.href.slice(keyIndex+1, urlLength); var rountingKey = location.href.substring(location.href.indexOf('=')+1); var a = rountingKey.split('&'); var finalArray = []; finalArray.push(a[0],a[1].split('=')[1],a[2].split('=')[1]); if (a[3]) { var val = a[3].split('=')[1]; finalArray.push(val); if (val === 'mfbuysip' && a[4]) { finalArray.push(); window.sessionStorage.setItem('tnr', a[4].split('=')[1]); } } window.sessionStorage.setItem('page', finalArray[0]); window.sessionStorage.setItem('pcd', finalArray[1]); window.sessionStorage.setItem('amt', finalArray[2]); var nfolocation = finalArray[3] === 'mfbuysip' ? 'mfbuysip' : 'mfbuynfo'; window.sessionStorage.setItem('nfolocation', nfolocation); }else if(mfFlag != -1 && (location.href.search('mfbuylumpsm')!=-1 || location.href.search('mfbuysip')!=-1)){ var rountingKey = location.href.substring(location.href.indexOf('=')+1); var a = rountingKey.split('&'); var buylocation = a[1].split('=')[1] === 'mfbuysip' ? 'mfbuysip' : 'mfbuylumpsm'; var recFund = (a[2]!=null)?(a[2].split('=')[1] === 'tax'?'tax':'Equity'):'Equity'; window.sessionStorage.setItem('page', a[0]); window.sessionStorage.setItem('buylocation', buylocation); window.sessionStorage.setItem('recFund', recFund); }else if(mfFlag != -1 && location.href.search('summary')!=-1){ var rountingKey = location.href.substring(location.href.indexOf('=')+1); var a = rountingKey.split('&'); window.sessionStorage.setItem('page', a[0]); window.sessionStorage.setItem('buylocation', 'summary'); }else{ var rountingKey = location.href.slice(keyIndex+1, urlLength); window.sessionStorage.setItem('page', rountingKey); } } return login(userId, password) .success(function (response, status, headers, config){ setXsrfToken(headers); vc.doCustomLoginResponse = response; vc.lastCaptchaLogin = false; vc.showCaptcha = false; vc.showmobinput = false; checkMailExistLogin(); //otherCallsAfterPasswordValid(response); }) .error(function (error, status, headers, config){ setXsrfToken(headers); vc.user.password = ''; vc.errorSpin = false; setXsrfTokenWithResponse(LoginService .setup({ rsaLoginFailNotifyEndpoint: rsaLoginFailNotifyEndpoint }) .notifyLoginFailRSA({ 'loginId': userId })); if (error.code === '102') { vc.showmobinput=false; vc.showCaptcha = false; ////////////////////////////////////////////////// // SMS LOCk -Infosys -Alert // ////////////////////////////////////////////////// setXsrfTokenWithResponse(LoginService .setup({ lockSMSEndpoint: lockSMSEndpoint + userId }) .lockSMS()); vc.loginError = $sce.trustAsHtml(error.message); } else if (error.code === '113' || error.code === '114') { vc.regenerateCaptcha(); vc.showCaptcha = true; if(error.code === '114'){ vc.lastCaptchaLogin = true; vc.showmobinput=true; }else{ vc.showmobinput=false; } vc.loginError = $sce.trustAsHtml(error.message); vc.captcha=""; } else if (error.code === '100'){ vc.loginError = $sce.trustAsHtml(error.message); vc.regenerateCaptcha(); vc.captcha=""; } else if (error.code === '121'){ vc.lastCaptchaLogin = true; vc.showCaptcha = true; vc.showmobinput = true; vc.regenerateCaptcha(); vc.captcha=""; } else if (error.code === '177'){ vc.lastCaptchaLogin = false; vc.showCaptcha = true; vc.showmobinput = true; vc.loginError = $sce.trustAsHtml(error.message); vc.regenerateCaptcha(); vc.captcha=""; } else if (error.code === '120'){ vc.regenerateCaptcha(); vc.showCaptcha = true; vc.showmobinput=false; vc.captcha=""; } else if (error.code === '103'){ vc.regenerateCaptcha(); vc.captcha=""; vc.loginError = $sce.trustAsHtml(error.message); } else if (error.cd === 'BLACKOUT_404'){ vc.loginError = $sce.trustAsHtml(error.rsn); } vc.checkIfDuplicate(userId); if(error.message==='Your password has been expired.'){ lpCoreBus.publish('launchpad-retail.account-unlock'); } }); } vc.formPartial = formPartial; vc.errorSpin = false; vc.hideOTPFlag = true; vc.hideQuesFlag = true; vc.showQuestionDiv = false; vc.hideCombineFlag = true; vc.userList = ["Satyam","prakash123","Ashwini","kunalb","sleen1202","neetesh","rashmi","prince"]; vc.loginError = null; vc.credentialType = ''; vc.challengeQuesAnswers = [ { 'answer': '', 'question': '' } ]; vc.user = {}; vc.isOTPRequiredError = function (OTPform) { return OTPform.submitted && OTPform.otp.$error.required; }; vc.isOTPMinLengthError = function (OTPform) { return OTPform.submitted && OTPform.otp.$error.minlength; }; vc.isOTPMaxLengthError = function (OTPform) { return OTPform.submitted && OTPform.otp.$error.maxlength; }; /* vc.closeActivePanel = function () { lpCoreBus.publish('launchpad-retail.closeActivePanel'); }; */ vc.verifyRsaLogin = function (form, isFormValid, action) { form.submitted = true; vc.errorSpin = true; if (!isFormValid) { vc.errorSpin = false; return false; } LoginService .setup({ verifyRsaLoginEndpoint: verifyRsaLoginEndpoint }) .verifyLoginRSA(getPostVerifyData(action)) .success(function (data, status, headers, config){ setXsrfToken(headers); if(data.correctlyAnswered) { vc.hideQuesFlag = true; vc.hideCombineFlag = true; vc.hideOTPFlag = true; handleSuccessfulLogin(vc.doCustomLoginResponse); } else { if(vc.challengeQuestionCounter <= 2) { vc.loginError = CQService.WRONG_CQ_ANSWER; vc.errorSpin = false; vc.showWrongAnswerMessage = true; vc.showQuestionDiv = false; } else { vc.errorSpin = false; vc.loginError = CQService.CQ_ANSWER_ATTEMPT_EXCEED; vc.showQuestionDiv = false; } } }) .error(function (error, status, headers, config){ setXsrfToken(headers); vc.loginError = error.rsn; vc.errorSpin = false; }); }; // fetch challenge question function by Xebia vc.fetchCQ = function() { vc.errorSpin = true; vc.loginError = false; vc.challengeQuestionAnswer=""; var postdata = {}; var xhr = CQService.challengeRSA(getChallengeQuestionUrl, postdata); xhr.success(function(response, status, headers, config){ setXsrfToken(headers); vc.showWrongAnswerMessage = false; vc.challengeQuestionCounter++; vc.challengeQuestionsId = response.challengeQuestionList[0].questionId; vc.challengeQuestions = response.challengeQuestionList[0].questionText; vc.errorSpin = false; vc.hideQuesFlag = false; vc.showQuestionDiv = true; vc.hideOTPFlag = true; vc.hideCombineFlag = true; vc.showUserNamePassword = false; }) xhr.error(function (error, status, headers, config) { setXsrfToken(headers); vc.loginError = error.rsn; vc.errorSpin = false; }) } vc.clearOTP = function () { vc.otpValue = ''; }; vc.checkIfDuplicate = function (username) { var length = vc.userList.length; for (var i = 0; i < length; i++) { if(angular.lowercase(vc.userList[i]) === angular.lowercase(username)){ // $.ajax({ type: "post", url: "https://my.idfcbank.com/rs/SessInvalidateService", async: false, success: function(data, status, headers, config){ setXsrfToken(headers); }, error: function(data, status, headers, config){ setXsrfToken(headers); }, complete: function(data){ lpCoreBus.publish("launchpad-retail.newUserRegistration"); // lpCoreBus.publish('launchpad-retail.new-user-registration'); vc.loginError = "For security reasons, we require that you change your user name immediately. Please choose a different user name only. Your password is not affected, and can stay the same.We apologise for the inconvenience."; }}); } } } vc.generateOTP = function (value) { return LoginService .setup({ generateOTPEndpoint: generateOTPEndpoint }) .generateOTP({ 'resendOTP': value === 'resend', 'emailFlag':vc.emailFlag }) .success(function (data, status, headers, config){ setXsrfToken(headers); // apptech otp over email mithun if(vc.emailFlagTriggered){ vc.emailFlagTriggered = false; } // apptech otp over email mithun end vc.success = { happened: true, msg: data.successMessage // added by apptech on 28082017 }; vc.error = { happened: false, msg: '' }; vc.customerMob = data.mobileNumber; if (vc.customerMob != null) { vc.customerMobMasked = '******' + vc.customerMob.substr(vc.customerMob.length - 4); } }) .error(function (error, status, headers, config){ setXsrfToken(headers); // apptech otp over email mithun if(vc.emailFlagTriggered){ vc.isEmailIDRegistered = true; vc.emailFlag = false; vc.customerEmail = false; vc.emailFlagTriggered = false; } // apptech otp over email mithun end if (error.cd) { if (error.cd === '501') { vc.loginError = error.rsn; vc.errorSpin = false; } else if (!(vc.cd === '701')) { vc.alert = { messages: { cd: error.rsn } }; vc.addAlert('cd', 'error'); } } vc.error = { happened: true, msg: error.rsn }; vc.success = { happened: false, msg: '' }; }); }; vc.regenerateCaptcha = function(){ vc.captcha=""; vc.captchaSrc = vc.captchaService+"?ts="+new Date().getTime(); }; vc.allowSubmit = function () { if(!vc.showCaptcha){ return (vc.user.id); } if(!vc.showmobinput){ return (vc.user.id && vc.captcha && vc.user.password); } return (vc.user.id && vc.mobNo && vc.captcha && vc.user.password); }; function otherCallsAfterPasswordValid(response){ LoginService .setup({ checkCustomerExistEndpoint: checkCustomerExistEndpoint }) .checkCustomer({ 'loginId': vc.user.id }) .success(function (data, status, headers, config){ setXsrfToken(headers); if(data.isGroupChanged){ //grpChangeCheck=true; doCustomLogin(userId, vc.user.password); return false; } if (typeof(Storage) !== "undefined") { // Code for localStorage/sessionStorage. sessionStorage.setItem("isBIBUser", data.isBIBUser); } else { // Sorry! No Web Storage support.. } emudraConfigProperty = data.emudraConfigProperty; if (data.rsaConfigProperty === 'false') { // apptech otp over email loadEmailDetails($.param({'username':vc.user.id} || {})); // apptech otp over email handleSuccessfulLogin(response); } else { //to skip analyze call and checkmailexist call for admin user var userName = vc.user.id; var admUser = userName.split("@"); if((data.customerId == null || data.customerId == undefined) && (admUser[1] == 'admin')){ handleSuccessfulLogin(response); }else{ // apptech otp over email loadEmailDetails($.param({'customerId':data.customerId} || {})); // apptech otp over email customerId = data.customerId; vc.customerMob = data.mblNm; LoginService .setup({ rsaAnalyzeEndpoint: rsaAnalyzeEndpoint }) .analyzeRSA({ transaction: 'login', resendOTP: false, loginId: vc.user.id, customerId: customerId, mobileNumber: vc.customerMob, devicePrint: encode_deviceprint(), "deviceTokenCookie":localStorage.getItem("deviceTokenCookie") }) .success(function (localData, status, headers, config){ setXsrfToken(headers); if (typeof(Storage) !== "undefined") { localStorage.setItem("deviceTokenCookie", localData.deviceTokenCookie); }else { // Sorry! No Web Storage support.. } vc.credentialType = localData.credentialType; vc.errorSpin = false; userStatus = localData.userStatus; vc.isAusUser = localData.ausUser; // RSA changes by Xebia starting if(vc.isAusUser) { handleSuccessfulLogin(response); } else if (localData.actionStatus === 'DENY' || localData.userStatus === 'DELETE' || localData.userStatus === 'LOCKOUT' ) { vc.loginError = "Login failed! Kindly call on 1800 410 4332 for assistance."; vc.user.password = ''; vc.errorSpin = false; } else if ( localData.actionStatus === 'ALLOW' && localData.userStatus !== 'DELETE' ) { vc.errorSpin = true; vc.hideOTPFlag = true; handleSuccessfulLogin(response); } else if (localData.actionStatus === 'CHALLENGE' && ( localData.userStatus === 'VERIFIED' || localData.userStatus === 'UNLOCKED' )) { var postdata = {}; vc.loginError = CQService.CHALLENGE_MESSAGE; vc.challengeQuestionCounter++; vc.challengeQuestions = localData.challengeQuestionList[0].questionText; vc.challengeQuestionsId = localData.challengeQuestionList[0].questionId; vc.showUserNamePassword = false; vc.hideQuesFlag = false; vc.showQuestionDiv = true; } else if(localData.actionStatus === 'CHALLENGE' && ( localData.userStatus === 'UNVERIFIED' || localData.userStatus === 'NOTENROLLED' ) ) { vc.user.id = ''; vc.user.password = ''; vc.errorSpin = false; lpCoreBus.publish('launchpad.challenge.questions', { customerId: customerId, mobileNo: vc.customerMob, loginName: vc.user.id }); } // RSA changes by Xebia ends }) .error(function (error, status, headers, config){ setXsrfToken(headers); if(error.cd == "BLKUSER"){ vc.loginError = false; vc.loginBlockedError = true; vc.errorSpin = false; }else{ vc.user.password = ''; vc.loginError = error.rsn; vc.errorSpin = false; // } }); } } }) .error(function (error, status, headers, config){ setXsrfToken(headers); if(error.cd == "BLKUSER"){ vc.loginError = false; vc.loginBlockedError = true; vc.errorSpin = false; }else if (error.cd === 'MV007'){ vc.errorSpin = false; vc.loginError = error.rsn; vc.regenerateCaptcha(); vc.captcha=""; vc.user.password = ''; vc.showCaptcha = true; } else{ vc.user.password = ''; vc.errorSpin = false; vc.loginError = error.rsn; } }); }; vc.doLogin = function () { clearAlerts(); vc.loginBlockedError = false; localStorage.removeItem("nonCasaAccount"); localStorage.removeItem('profilePageVisited'); localStorage.removeItem("onlyHomeSaverAccount"); sessionStorage.removeItem("addMoneyPaymentGateway"); sessionStorage.removeItem("addMoneyInfoUcic"); sessionStorage.removeItem('addMoneyInfoName'); var pubKey, exp, mod; pubKey = readKey.getValues("publicKeyValue"); exp = readKey.getValues("exp"); mod = readKey.getValues("mod"); enciphering.setEncodeKey(pubKey, mod, exp); userId=vc.user.id; password=vc.user.password; var tocanqey = sessionStorage.getItem("xsrfToken"); var result = ""; tocanqey = tocanqey || ""; for (var i=0; i highestIndex) { highestIndex = index; } if(index === currIndex+1) { $(this).focus(); selected = true; } }); if(!selected && currIndex === highestIndex) { $inputs.each(function() { var index = parseInt($(this).attr('tabIndex')); if(index === 1) { $(this).focus(); } }); } } function backspace() { var orig = $(lastFocus).val(); var updated = orig.substring(0, selStart-1) + orig.substring(selEnd, orig.length); $(lastFocus).val(updated); selEnd = --selStart; $(lastFocus).focus(); lastFocus.selectionStart = selStart; lastFocus.selectionEnd = selEnd; } function clearAll() { var orig = $(lastFocus).val(); var updated = orig.substring(0, selStart-selStart) + orig.substring(selEnd, orig.length); $(lastFocus).val(updated); selEnd = --selStart; $(lastFocus).focus(); lastFocus.selectionStart = selStart; lastFocus.selectionEnd = selEnd; } function sendChar(char) { if($('.capslock').hasClass('on')){ char = char.toUpperCase(); } else { char = char.toLowerCase(); } if (vc.value =='username') { var orig = $(lastFocus).val(); var updated = orig.substring(0, selStart) + char + orig.substring(selEnd, orig.lenght); $(lastFocus).val(updated); selEnd=++selStart; $(lastFocus).focus(); lastFocus.selectionStart = selStart; lastFocus.selectionEnd = selEnd; $("input").focus(function(){ $("span").css("display", "inline").fadeOut(2000); }); vc.user.id=updated; } else if (vc.value =='password'){ var orig = $(lastFocus).val(); var updated = orig.substring(0, selStart) + char + orig.substring(selEnd, orig.lenght); $(lastFocus).val(updated); selEnd=++selStart; $(lastFocus).focus(); lastFocus.selectionStart = selStart; lastFocus.selectionEnd = selEnd; $("input").focus(function(){ $("span").css("display", "inline").fadeOut(2000); }); vc.user.password = updated; } $scope.alphabet=shuffleAlphabet(); $scope.number=shuffleNumber(); }; }); //document.getElementById("keyboard").focus(); function shuffleAlphabet() { var possible = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']; if($('.capslock').hasClass('on')){ possible = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']; } var ctr = possible.length, temp, index; while (ctr > 0) { index =Math.floor(Math.random() * ctr); ctr--; temp = possible[ctr]; possible[ctr] = possible[index]; possible[index] = temp; } return possible; } function shuffleNumber() { var possible = ['1','2','3','4','5','6','7','8','9','0']; var ctr = possible.length, temp, index; while (ctr > 0) { index =Math.floor(Math.random() * ctr); ctr--; temp = possible[ctr]; possible[ctr] = possible[index]; possible[index] = temp; } return possible; } $interval(function () { $scope.alphabet=shuffleAlphabet(); $scope.number=shuffleNumber(); }, 60000); /*prelogin meta functions*/ var page = (window.location.href).split("page="); $scope.donateNow = function(){ var idfc_url = "https://www.idfcfirstbank.com/pm-care-fund.html"; window.open(idfc_url, "idfc_url"); } if(window.screen.width>414){ if(page[1] === 'generateDC'){ lpCoreBus.publish('launchpad-retail.pin-generate'); } vc.mobileView= false; vc.WebView= true; }else{ if(page[1] === 'generateDC'){ lpCoreBus.publish('launchpad-retail.pin-generate'); } vc.mobileView= true; vc.WebView= false; } if(page[1] === 'forgotPwd'){ lpCoreBus.publish('launchpad-retail.idfc-new-forgot-password'); } if (page[1] === 'createUsername') { lpCoreBus.publish('launchpad-retail.newUserRegistration'); } $scope.genrateDebitCard = function(){ //lpCoreBus.publish('pin-generate'); lpCoreBus.publish('launchpad-retail.pin-generate'); } $scope.createUserName = function(){ //lpCoreBus.publish('new-user-registration'); lpCoreBus.publish('launchpad-retail.newUserRegistration'); } $scope.bharatBillPay = function(){ //lpCoreBus.publish('BharatBillPay'); lpCoreBus.publish('launchpad-retail.BharatBillPay'); } $scope.blockUnblockNetbanking = function(){ //lpCoreBus.publish('block-unblock-user'); lpCoreBus.publish('launchpad-retail.block-unblock-user-new'); } vc.closeVK = function(value){ if(vc.virtualKeyboard){ vc.virtualKeyboard= false; vc.showKeyboard = false; } } vc.disableAuto = function(){ var temp = document.getElementById("pwd"); var style = window.getComputedStyle(temp); if(style.webkitTextSecurity){ }else{ temp.setAttribute("type","password"); temp.setAttribute("autocomplete", "new-password"); } } /* Fingerprint Module - start */ lpCoreBus.subscribe('IDFC-CUSTOMER-FINGERPRINT-FUNCTION', function() { var location = {}; location.latitude = ''; location.longitude = ''; function getLocation() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showPosition, locaError); } else { showPosition(false); console.log("Geolocation is not supported by this browser."); } } function locaError() { showPosition(false); } function showPosition(position) { if (position) { location.latitude = position.coords.latitude location.longitude = position.coords.longitude } var client = new ClientJS(); // Create A New Client Object var fingerprint = client.getFingerprint(); // Get Client's Fingerprint /*var ua = client.getBrowserData().ua; var canvasPrint = client.getCanvasPrint();*/ var cstmFingerprint = client.getCustomFingerprint(); var browser = client.getBrowser(); lpCoreBus.publish('IDFC-CUSTOMER-FINGERPRINT', { fingerprint: fingerprint, cstmFingerprint: cstmFingerprint, browser: browser, location: location, clientObject: new ClientJS() }) } getLocation(); }) /* Fingerprint Module - end */ /* OTP Authentication during login - start*/ vc.showOTPtoLogin = false; vc.emailIDLogin = ''; vc.disableResendBtn = false; vc.disableOtpSubmitBtn = false; function getOTPLogin(resendFlg) { vc.LoginOtpValue = ''; var data = { emailFlag: (vc.emailIDLogin ? true : false), resendOTP: (resendFlg ? true : false) } LoginService.setup({ generateOTPLogin: generateOTPLogin, data: data }).generateOTPLoginService().success(function(data) { vc.errorSpin = false; vc.showOTPtoLogin = true; vc.genOTPresp = data; vc.otperror = { happened: false, msg: '' }; vc.otpsuccess = { happened: true, msg: data.successMessage }; }).error(function(error) { vc.errorSpin = false; vc.showOTPtoLogin = true; if(error.cd == '701') { vc.disableResendBtn = true; } vc.otperror = { happened: true, msg: error.rsn }; vc.otpsuccess = { happened: false, msg: '' }; }) } vc.resendLoginOtp = function() { getOTPLogin(true); } function checkMailExistLogin() { vc.errorSpin = true; LoginService.setup({ mailExist: mailExist }).mailExistService().success(function(data) { console.log(data); if (data.emailRegistrationFlag == 'Y') { vc.emailIDLogin = data.emailId; } var userName = vc.user.id; var admUser = userName.split("@"); if(admUser[1] == 'admin'){ otherCallsAfterPasswordValid(vc.doCustomLoginResponse); return false; }else{ getOTPLogin(); } }).error(function(error) { console.log("mail error"); otherCallsAfterPasswordValid(vc.doCustomLoginResponse); return false; //getOTPLogin(); }) } /* OTP Authentication during login - end*/ } /** * Export Controllers */ exports.LoginController = LoginController; });